package com.kmust.dream.wanderingdream.shoppingcart.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * 
 * @TableName shopping_cart_item
 */
@TableName(value ="shopping_cart_item")
@Data
public class ShoppingCartItem implements Serializable {
    /**
     * 购物车记录id
     */
    @TableId(value = "item_id", type = IdType.AUTO)
    private Integer itemId;

    /**
     * 用户的id
     */
    @TableField(value = "username")
    private String username;

    /**
     * sku的id，实为外键，方便不设
     */
    @TableField(value = "product_sku_id")
    private Integer productSkuId;

    /**
     * 买的个数
     */
    @TableField(value = "item_number")
    private Integer itemNumber;

    /**
     * item的描述
     */
    @TableField(value = "item_desc")
    private String itemDesc;

    /**
     * 创建的时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    /**
     * 是否显示
     */
    @TableField(value = "show")
    private Boolean show;

    /**
     * 当前订单的version
     */
    @TableField(value = "version")
    private Integer version;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ShoppingCartItem other = (ShoppingCartItem) that;
        return (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()))
            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
            && (this.getProductSkuId() == null ? other.getProductSkuId() == null : this.getProductSkuId().equals(other.getProductSkuId()))
            && (this.getItemNumber() == null ? other.getItemNumber() == null : this.getItemNumber().equals(other.getItemNumber()))
            && (this.getItemDesc() == null ? other.getItemDesc() == null : this.getItemDesc().equals(other.getItemDesc()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getShow() == null ? other.getShow() == null : this.getShow().equals(other.getShow()))
            && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode());
        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
        result = prime * result + ((getProductSkuId() == null) ? 0 : getProductSkuId().hashCode());
        result = prime * result + ((getItemNumber() == null) ? 0 : getItemNumber().hashCode());
        result = prime * result + ((getItemDesc() == null) ? 0 : getItemDesc().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getShow() == null) ? 0 : getShow().hashCode());
        result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", itemId=").append(itemId);
        sb.append(", username=").append(username);
        sb.append(", productSkuId=").append(productSkuId);
        sb.append(", itemNumber=").append(itemNumber);
        sb.append(", itemDesc=").append(itemDesc);
        sb.append(", createTime=").append(createTime);
        sb.append(", show=").append(show);
        sb.append(", version=").append(version);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}